package my.ts.code.util;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import android.graphics.drawable.Drawable;

public class Util {

	public static Drawable getImage(String link) {
		URLConnection url;
		Drawable drawAble = null;
		if (link != null)
			try {
				String srcName = link;
				url = new URL(link.replace(" ", "%20")).openConnection();
				url.setConnectTimeout(1000);
				url.setReadTimeout(1000);
				InputStream is = url.getInputStream();
				drawAble = Drawable.createFromStream(is, srcName);

			} catch (MalformedURLException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		return drawAble;
	}

}
